#include<stdio.h>
#include <stdbool.h>
#include <setjmp.h>

static jmp_buf start;

int main()
{
    
    int x;
    bool quit=false;
    if (setjmp(start) == 1)
    {
       printf("1=caculate\n");
       printf("2=conversion\n");
       printf("Please give your choice:");
       scanf("%d",&x); 
    }
    if (x==1)
    {
        int a;
        int b;
        int c;
        int op;
        printf("input the first number:\n");
        scanf("%d",&a);
        printf("input the operation:\n");
        getchar();
        op=getchar(); 
        printf("input the 2th number:\r\n");
        scanf("%d",&b);
        switch(op)
        {
            case '+':
                c=a+b;
                break;
            case '-':
                c=a-b;
                break;
            case '*':
                c=a*b;
                break;
            case '/':
                c=a/b;
                break;
            case 27:
                quit=true;
                break;
            default:
                break;
        }
        printf("the result is:%d\n",c); 

    }

    else if(x==2)
    {
        printf("In this mode,\n");
        printf("you can convert Fahrenheit to Celsius.\n");
        float F,C;
        printf("Please enter the temperature in Fahrenheit:");
	    scanf("%f",&F);
        C=(F-32)*5/9;
        printf("The Celsius temperature is:%.2f\n",C);
    }

       while(1)
    {
       
       
        if(quit==true)
        break;
        longjmp(start, 1);
    }

    return 0;
}

